package com.itheima.search.domain;

import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.Date;
import java.util.HashMap;

@Data
@ToString
@NoArgsConstructor
public class NewsVO {
    //新闻ID
    private String newsId;
    //新闻标题
    private String title;
    //来源
    private String source;
    //新闻类型
    private String newsType;
    //内容
    private String content;
    //状态
    private Integer status;
    //创建时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    public NewsVO(HashMap<String, String> map){
        this.newsId = map.get("newsId");
        this.title = map.get("title");
        this.newsType = "新闻";
        this.source = map.get("source");
        this.content = map.get("content");
        this.status = Integer.parseInt(map.get("status"));
        this.createTime = DateUtil.parse(map.get("createTime"), "yyyy-MM-dd HH:mm:ss");
    }

}
